<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>

<html>
<head>
    <%@ include file="/common.jsp" %>
    <title>商户登录</title>
    <%--<link rel="stylesheet" type="text/css" href="../css/phone.css">
    <link rel="stylesheet" type="text/css" href="../css/weui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/jquery-weui.css">
    <link rel="stylesheet" type="text/css" href="../css/demos.css">
    <link rel="stylesheet" type="text/css" href="../statics/aui/css/aui.css"/>--%>
    <script type="text/javascript" src="../statics/libs/jquery.min.js"></script>
    <script type="text/javascript" src="../js/login.js"></script>

    <link rel="stylesheet" type="text/css" href="${ctx}/css/phone.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/demos.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/statics/aui/css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx }/css/weui.min.css"/>
</head>

<body>
<input type="hidden" id="openid" value="${openid}" name="openid">
<section class="aui-content">
    <ul class="aui-list">
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-media" style="width: 4rem;">手机号</div>
                <div class="aui-list-item-inner  ">
                    <input type="tel" id="mobile" name="mobile" placeholder="请输入您的手机号码" maxlength="11">
                </div>
            </div>
        </li>

        <li class="aui-list-item   ">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-media" style="width: 4rem;">验证码</div>
                <div class="aui-list-item-inner  ">
                    <input type="tel" id="validationCode" maxlength="8" name="validationCode" style="width: 8rem;"
                           placeholder="请输入短信验证码">
                    <input type="button" class="aui-btn aui-btn-warning" id="checkSendOutCode" value="发送验证码"
                           onclick="clickButton(this)"/>
                </div>
            </div>
        </li>
    </ul>
</section>

<section class="aui-content" style="margin-top: 14px; padding-left: 20px; padding-right: 20px;">
    <p>
    <div class="aui-btn aui-btn-info  aui-btn-block" onclick="sureLogin()">登陆</div>
    </p>
</section>

<section class="aui-content" style="margin-top: 14px; padding-left: 20px; padding-right: 20px;">
    <p>
    <div class="aui-btn aui-btn-info  aui-btn-block" onclick="location='../auth/register'">激活</div>
    </p>
</section>

<section class="aui-content" style="margin-top: 14px; padding-left: 20px; padding-right: 20px;">
    <p style="text-align: center">
        首次登陆请先激活帐号
    </p>
</section>

<div id="dialogs">
    <div class="js_dialog" id="iosDialog2" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__bd" id="DialogMessage"></div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary DeleteDefault">确定</a>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    var $iosDialog2 = $('#iosDialog2');
    $('#dialogs').on('click', '.DeleteDefault', function () { //取消按钮事件
        $(this).parents('.js_dialog').fadeOut(200);
    });

    /**
     * 登陆
     */
    function sureLogin() {
        var mobile = $("#mobile").val();
        var validationCode = $("#validationCode").val();
        if (mobile.trim() == null || mobile.trim() == "" || mobile.trim() == "请输入您的手机号码") {
            $("#DialogMessage").html("请填写手机号码");
            $iosDialog2.fadeIn(200);
            return;
        }else  if(!(/^1[34578]\d{9}$/.test(mobile.trim()))){
    		$("#DialogMessage").html("请输入正确的手机号");
            $iosDialog2.fadeIn(200);
            return ;
        }
        if (validationCode.trim() == null || validationCode.trim() == "" || validationCode.trim() == "请输入短信验证码") {
            $("#DialogMessage").html("请输入验证码");
            $iosDialog2.fadeIn(200);
            return;
        }
        $.ajax({
            type: "POST",
            url: "../auth/sureLogin",
            data: {
                validationCode: validationCode,
                mobile: mobile
            },
            dataType: "json",
            success: function (result) {
                if (result.code != "500") {
                    window.location.href = "../auth/loginSuccess";
                } else {
                    $("#DialogMessage").html("" + result.msg);
                    $iosDialog2.fadeIn(200);
                }
            }
        });
    }
</script>

</body>
</html>
